import { CardEvent } from '../../api/CardEvent';
import { Room } from '../../api/Room';
import { Card } from '../base/Card';

export class AssignmentOrder extends Card {
	title(room: Room, user: string): string {
		return '差遣令';
	}

	desc(room: Room, user: string): string {
		return '获得指定部门场上随机1张官员牌。';
	}

	use(room: Room, user: string, target: string): void {
		var dept = room.getDept(target);
		if (!dept) return;

		var index = Math.floor(Math.random() * dept.fieldCards.length);
		var card = dept.fieldCards[index];
		CardEvent.addCard(room, user, card);
		CardEvent.destroyFieldCard(room, target, index);
	}

	target(room: Room, user: string): string {
		return 'all';
	}
}
